$(function(){
	var basePath=$("#basepath").val();
	$("#chooseScoreFilter_go").click(function(){
		var clgId=$("#chooseScoreFilter_form select[name='college']").val();
		if(clgId==0){
			return;
		}
		window.location=basePath+"admin/choose/showScoreList/"+clgId+"/1";
	});
	$("#score_add_excel").click(function(){
		$("#score_add_excel_box_confirm").unbind();
		$("#score_add_excel_box_file_name").html("未选择");
		$("#score_add_excel_box_alert_container").html("");
		$("#score_add_excel_box_file").show();
		$("#score_add_excel_box_progress").hide();
		$("#score_add_excel_box_progress div").css("width","0%");
	});
	$("#score_add_excel_box_file input[type='file']").fileupload({  
	    url:basePath+"admin/choose/insertScoreByExcel",
	    autoUpload:false,
	    done:function(e,result){  
			noty({text:"导入完成,正在处理"});
	    	window.location=basePath+"admin/choose/showInsertReport";
	    } ,
	    progress:function(e,result){
	    	var progress=parseInt(result.loaded / result.total * 100, 10);
	    	$("#score_add_excel_box_progress div").css("width",progress+"%");
	    },
	    add:function(e,result){
	    	var fileName=result.files[0].name.toLowerCase();
			var isExcel=/(\.xlsx{0,1})$/.test(fileName);
			if(isExcel){
				$("#score_add_excel_box_alert_container .wrong_file_error").alert('close');
				$("#score_add_excel_box_file_name").html(fileName);
			}else{
				makeAlert("请选择正确的excel文件","error",$("#score_add_excel_box_alert_container"),"wrong_file_error");
				$("#score_add_excel_box_file_name").html("请选择");
				return;
			}
			$("#score_add_excel_box_confirm").unbind();
			$("#score_add_excel_box_confirm").click(function(){
				$("#score_add_excel_box_file_name").html("正在上传:"+fileName);
				$("#score_add_excel_box_file").hide();
				$("#score_add_excel_box_progress").show();
				result.submit();
			});
	    }
	}) ;
});